﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAcquisition
{
    internal class Config
    {
        #region 属性
        /// <summary>配置文件路径
        /// 
        /// </summary>
        static String configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.ini");

        /// <summary>ini文件操作工具
        /// 
        /// </summary>
        private static IniFile ini = new IniFile(configPath);

        /// <summary>播报测试数据
        /// 
        /// </summary>
        private static string BroadcastTestDataKey = "BroadcastTestData";

        /// <summary>播报远端异常
        /// 
        /// </summary>
        private static string BroadcastRemoteErrorKey = "BroadcastRemoteError";

        /// <summary>播报启动
        /// 
        /// </summary>
        private static string BroadcastStartKey = "BroadcastStart";

        /// <summary>压力量程
        /// 
        /// </summary>
        private static string PressFixedRangeKey = "PressFixedRange";
        #endregion

        #region

        /// <summary> 播报测试数据
        /// 
        /// </summary>
        public static bool BroadcastTestData
        {
            get
            {
                return ini.ReadBool(BroadcastTestDataKey, "Enable", true);
            }
            set
            {
                ini.Write(BroadcastTestDataKey, "Enable", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 播报测试数据时间间隔
        /// 
        /// </summary>
        public static int BroadcastTestDataTimeInterval
        {
            get
            {
                return ini.ReadInt(BroadcastTestDataKey, "TimeInterval", 20);
            }
            set
            {
                ini.Write(BroadcastTestDataKey, "TimeInterval", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 播报远端异常
        /// 
        /// </summary>
        public static bool BroadcastRemoteError
        {
            get
            {
                return ini.ReadBool(BroadcastRemoteErrorKey, "Enable", false);
            }
            set
            {
                ini.Write(BroadcastRemoteErrorKey, "Enable", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 播报远端异常间隔
        /// 
        /// </summary>
        public static int BroadcastRemoteErrorTimeInterval
        {
            get
            {
                return ini.ReadInt(BroadcastRemoteErrorKey, "TimeInterval", 20);
            }
            set
            {
                ini.Write(BroadcastRemoteErrorKey, "TimeInterval", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 播报启动
        /// 
        /// </summary>
        public static bool BroadcastStart
        {
            get
            {
                return ini.ReadBool(BroadcastStartKey, "Enable", false);
            }
            set
            {
                ini.Write(BroadcastStartKey, "Enable", value);
                ini.UpdateFile();
            }
        }

        public static string BroadcastStartMessage
        {
            get
            {
                return ini.Read(BroadcastStartKey, "message", "开机，请建立工程");
            }
            set
            {
                ini.Write(BroadcastStartKey, "message", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 压力固定量程
        /// 
        /// </summary>
        public static bool PressFixedRange
        {
            get
            {
                return ini.ReadBool(PressFixedRangeKey, "Enable", true);
            }
            set
            {
                ini.Write(PressFixedRangeKey, "Enable", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 压力固定量程
        /// 
        /// </summary>
        public static double PressRange
        {
            get
            {
                return ini.ReadDouble(PressFixedRangeKey, "Value", 30);
            }
            set
            {
                ini.Write(PressFixedRangeKey, "Value", value);
                ini.UpdateFile();
            }
        }
        #endregion
    }
}
